var express = require('express')
var connection = require('../db/db_utill');

var router = express.Router()

router.post('/issue_topic', function (req, res) {
  //获取话题内容
  var body = req.body

  var inserts = [null, body.title, body.html_content, body.topic_pic, body.topic_category, 0, 0, body.user_id, null, 1]
  connection.query(`INSERT INTO topic_info value(?,?,?,?,?,?,?,?,?,?)`, inserts, function (error, results, fields) {
    if (error) {
      throw error;
    } else {
      // 服务端重定向针对异步请求无效
      return res.json({
        status: 200,
        message: '发布成功'
      })
    }
  });

})

module.exports = router;